module ShowCountTest(tests) where

import Test.HUnit
import ShowCount

countLinesTests =
    TestList["empty" ~: 0 @=? countLines "",
             "one" ~: 1 @=? countLines "foo\n",
             "many" ~: 3 @=? countLines "a\nbc\nd\n",
             "no trailing newline" ~: 2 @=? countLines "a\nbc"]

countWordsTests =
    TestList["empty" ~: 0 @=? countWords "",
             "one" ~: 1 @=? countWords "abc",
             "two" ~: 2 @=? countWords "two words",
             "many" ~: 5 @=? countWords "there are five words here",
             "special chars" ~: 3 @=? countWords "a\tb\nc"]

countCharsTests =
    TestList["empty" ~: 0 @=? countChars "",
             "one" ~: 1 @=? countChars "a",
             "many" ~: 4 @=? countChars "four",
             "special chars" ~: 5 @=? countChars "a\tb\nc"]

showCountTests =
    TestList["show output" ~: "3\n" @=? (showCount countLines) "a\nbc\nd\n"]

tests = TestList[countLinesTests, countWordsTests, countCharsTests,
                 showCountTests]
